﻿using System;
using System.Windows.Forms;
using FastNET.CleanAct.Client.ManagerEngineBusiness.DataObjects;
using FastNET.CleanAct.Common.Repository;

namespace FastNET.CleanAct.Tools.HomeTemplateEditor.Dialogs
{
    internal partial class SelectPackage : Form
    {
        public SelectPackage()
        {
            InitializeComponent();
        }

        private void SelectPackage_Load(object sender, EventArgs e)
        {
            PackageList.DataSource = Package.Retrieve();
            PackageList.DisplayMember = "Name";
            PackageList.ValueMember = "ID";
        }

        public Identity? SelectedPackage
        {
            get
            {
                return PackageList.SelectedItem != null ? (Identity?)((Package)PackageList.SelectedItem).ID : null;
            }
        }

        private void PackageList_SelectedIndexChanged(object sender, EventArgs e)
        {
            SelectButton.Enabled = (PackageList.SelectedValue != null);
        }
    }
}
